25#include <Eigen/SparseCore>
26#include <Eigen/SparseQR>
27#include <Eigen/SparseCholesky>
28#include <Eigen/OrderingMethods>
79 Eigen::SparseMatrix<double>
A_;
86 Eigen::SparseQR<Eigen::SparseMatrix<double>, Eigen::NaturalOrdering<int>>
qr_;
87 Eigen::SimplicialLDLT<Eigen::SparseMatrix<double>>
ldlt_;
90 Eigen::SparseMatrix<double>
R_;
91 Eigen::SparseMatrix<double>
Rt_;
92 Eigen::PermutationMatrix<Eigen::Dynamic, Eigen::Dynamic, int>
R_perm_;
133 SolverEigen(
const ProblemPtr& _wolf_problem,
const YAML::Node& _params);
143 bool failed()
const override;
163 const Eigen::SparseMatrix<double>&
getJacobian()
const;
189 const LocalParametrizationBasePtr& local_param)
const override;
193 bool checkDerived(std::string prefix =
"")
const override;
Gauss-Newton solver using sparse linear solvers through Eigen (no ceres dependency)
Definition: solver_eigen.h:58
unsigned int n_rows_
Rows of the stacked jacobian.
Definition: solver_eigen.h:75
SolverEigen(const ProblemPtr &_wolf_problem, const YAML::Node &_params)
Constructor from the problem and the YAML parameters.
Definition: solver_eigen.cpp:92
void reindex()
Recomputes the column of each non-fixed state block and the row of each factor (if structure changed)
Definition: solver_eigen.cpp:365
unsigned int max_num_iterations_
Maximum number of iterations.
Definition: solver_eigen.h:95
bool hasLocalParametrizationDerived(const StateBlockPtr &st) const override
Returns whether a state block has a local parametrization in the derived solver.
Definition: solver_eigen.cpp:1030
bool converged_
Terminated by convergence.
Definition: solver_eigen.h:107
unsigned int line_search_steps_
Step halvings of the backtracking line search.
Definition: solver_eigen.h:113
std::map< FactorBasePtr, unsigned int > fac_2_row_
First row of each factor.
Definition: solver_eigen.h:71
double linear_solver_time_
Time spent in linear solves.
Definition: solver_eigen.h:120
std::string getLinearSolverName() const
Linear solver and its implementation, e.g. "cholesky (CHOLMOD)" or "qr (Eigen SparseQR)".
Definition: solver_eigen.cpp:1269
std::string termination_message_
Termination message.
Definition: solver_eigen.h:110
std::set< StateBlockPtr > fixed_state_blocks_
Registered fixed state blocks.
Definition: solver_eigen.h:73
unsigned int n_failed_
Solves terminated by failure.
Definition: solver_eigen.h:127
double parameter_tolerance_
Convergence tolerance on the step size.
Definition: solver_eigen.h:97
bool linearize(bool _apply_loss)
Definition: solver_eigen.cpp:445
Eigen::SparseMatrix< double > A_
Stacked jacobian (weighted by the loss function if applicable)
Definition: solver_eigen.h:79
WOLF_SOLVER_CREATE(SolverEigen)
void printProfilingDerived(std::ostream &_stream) const override
Prints the profiling of the derived solver.
Definition: solver_eigen.cpp:1097
unsigned int n_no_convergence_
Solves terminated without convergence.
Definition: solver_eigen.h:128
unsigned int n_cols_
Columns of the stacked jacobian.
Definition: solver_eigen.h:76
unsigned int successful_steps_
Accepted Gauss-Newton steps.
Definition: solver_eigen.h:111
Eigen::PermutationMatrix< Eigen::Dynamic, Eigen::Dynamic, int > R_perm_
Column permutation of the QR.
Definition: solver_eigen.h:92
const Eigen::SparseMatrix< double > & getJacobian() const
Stacked jacobian of the last linearization (with loss function weights)
Definition: solver_eigen.h:223
double initialCost() const override
Returns the initial cost of the last solve.
Definition: solver_eigen.cpp:1082
unsigned int min_num_iterations_
Iterations during which the solver cannot be interrupted.
Definition: solver_eigen.h:100
bool stopped_
Terminated by interruption.
Definition: solver_eigen.h:109
Eigen::VectorXd b_
Stacked residuals (weighted by the loss function if applicable)
Definition: solver_eigen.h:80
void addStateBlockDerived(const StateBlockPtr &state_ptr) override
Adds a state block to the derived solver.
Definition: solver_eigen.cpp:966
void applyIncrement(const Eigen::VectorXd &_dx)
Applies an increment (in the tangent space) to the non-fixed state blocks.
Definition: solver_eigen.cpp:590
bool isStateBlockFixedDerived(const StateBlockPtr &st) const override
Returns whether a state block is fixed in the derived solver.
Definition: solver_eigen.cpp:1019
bool isStateBlockRegisteredDerived(const StateBlockPtr &state_ptr) const override
Returns whether a state block is in the derived solver.
Definition: solver_eigen.cpp:1014
unsigned int n_linear_solves_
Number of linear solves.
Definition: solver_eigen.h:115
LinearSolverType getLinearSolverType() const
Returns the linear solver type.
Definition: solver_eigen.h:218
std::string briefReport() const
One line report of the last solve (as ceres::Solver::Summary::BriefReport())
Definition: solver_eigen.cpp:1187
unsigned int n_convergence_
Solves terminated by convergence.
Definition: solver_eigen.h:125
LinearSolverType linear_solver_
Linear solver type.
Definition: solver_eigen.h:84
double cost_
Cost at the current estimate.
Definition: solver_eigen.h:81
int sizeStateBlocksEstimatedDerived() const override
Returns the total size of the estimated state blocks in the derived solver.
Definition: solver_eigen.cpp:1045
Eigen::SparseMatrix< double > Rt_
Transpose of R_.
Definition: solver_eigen.h:91
bool computeCovarianceBlocks(const std::vector< std::pair< StateBlockPtr, StateBlockPtr > > &_pairs)
Computes and stores in the problem the covariance blocks of the given pairs of state blocks.
Definition: solver_eigen.cpp:868
unsigned int n_linearizations_
Number of linearizations.
Definition: solver_eigen.h:114
std::string terminationType() const
Definition: solver_eigen.cpp:1179
unsigned int iterations() const override
Returns the number of iterations of the last solve.
Definition: solver_eigen.cpp:1077
bool failed() const override
Returns whether the last solve failed.
Definition: solver_eigen.cpp:1067
void updateStateBlockStatusDerived(const StateBlockPtr &state_ptr) override
Updates the fixed/unfixed status of a state block in the derived solver.
Definition: solver_eigen.cpp:987
Eigen::SparseQR< Eigen::SparseMatrix< double >, Eigen::NaturalOrdering< int > > qr_
Columns ordered in reindex()
Definition: solver_eigen.h:86
std::unique_ptr< SuiteSparseSolvers > suitesparse_
SPQR and CHOLMOD (defined only if SuiteSparse was found)
Definition: solver_eigen.h:89
double function_tolerance_
Convergence tolerance on the cost change.
Definition: solver_eigen.h:96
double minimizer_time_
Time of the minimization stage.
Definition: solver_eigen.h:117
std::map< StateBlockPtr, LocalParametrizationBasePtr > sb_2_local_param_
Local param of each state block.
Definition: solver_eigen.h:72
unsigned int n_iter_max_
Maximum iterations of a single solve.
Definition: solver_eigen.h:124
LinearSolverType
Linear solver type.
Definition: solver_eigen.h:63
double gradient_tolerance_
Convergence tolerance on the gradient.
Definition: solver_eigen.h:98
int numStateBlocksEstimatedDerived() const override
Returns the number of estimated state blocks in the derived solver.
Definition: solver_eigen.cpp:1035
void updateStateBlockLocalParametrizationDerived(const StateBlockPtr &state_ptr) override
Updates the local parametrization of a state block in the derived solver.
Definition: solver_eigen.cpp:999
bool hasThisLocalParametrizationDerived(const StateBlockPtr &st, const LocalParametrizationBasePtr &local_param) const override
Returns whether a state block has a given local parametrization in the derived solver.
Definition: solver_eigen.cpp:1024
bool failed_
Terminated by failure.
Definition: solver_eigen.h:108
Eigen::MatrixXd solveNormalEquations(const Eigen::MatrixXd &_E) const
Solves (AᵀA)·X = E using the last factorization.
Definition: solver_eigen.cpp:574
bool converged() const override
Returns whether the last solve converged.
Definition: solver_eigen.cpp:1062
double total_time_
Total time of the solve.
Definition: solver_eigen.h:106
void removeFactorDerived(const FactorBasePtr &fac_ptr) override
Removes a factor from the derived solver.
Definition: solver_eigen.cpp:958
std::string solveDerived(const ReportVerbosity report_level) override
Solves the problem in the derived solver, returning the report.
Definition: solver_eigen.cpp:154
Eigen::SimplicialLDLT< Eigen::SparseMatrix< double > > ldlt_
Eigen's Cholesky (LDLT) of the normal equations.
Definition: solver_eigen.h:87
std::string fullReport() const
Full report of the last solve (as ceres::Solver::Summary::FullReport())
Definition: solver_eigen.cpp:1196
bool isFactorRegisteredDerived(const FactorBasePtr &fac_ptr) const override
Returns whether a factor is in the derived solver.
Definition: solver_eigen.cpp:1009
void addFactorDerived(const FactorBasePtr &fac_ptr) override
Adds a factor to the derived solver.
Definition: solver_eigen.cpp:948
bool computeCovariancesDerived(const CovarianceBlocksToBeComputed _blocks) override
Computes the covariances of the specified blocks in the derived solver.
Definition: solver_eigen.cpp:610
bool wasStopped() const override
Returns whether the last solve was stopped (interrupted by a problem change)
Definition: solver_eigen.cpp:1072
bool checkDerived(std::string prefix="") const override
Checks the consistency of the derived solver.
Definition: solver_eigen.cpp:1110
double postprocessor_time_
Time of the postprocessing stage.
Definition: solver_eigen.h:118
double linearization_time_
Time spent linearizing.
Definition: solver_eigen.h:119
double finalCost() const override
Returns the final cost of the last solve.
Definition: solver_eigen.cpp:1087
bool interrupt_on_problem_change_
Interrupt the solver if the problem changed (as SolverCeres)
Definition: solver_eigen.h:99
double totalTime() const override
Returns the total time of the last solve.
Definition: solver_eigen.cpp:1092
double initial_cost_
Cost before the solve.
Definition: solver_eigen.h:104
unsigned int unsuccessful_steps_
Rejected Gauss-Newton steps.
Definition: solver_eigen.h:112
int sizeFactorsDerived() const override
Returns the total residual size of the factors in the derived solver.
Definition: solver_eigen.cpp:1053
unsigned int iterations_
Number of iterations.
Definition: solver_eigen.h:103
double preprocessor_time_
Time of the preprocessing stage.
Definition: solver_eigen.h:116
Eigen::VectorXd solveIncrement() const
Solves A_·dx = -b_ using the last factorization.
Definition: solver_eigen.cpp:557
std::map< StateBlockPtr, unsigned int > sb_2_col_
First column of each non-fixed state block.
Definition: solver_eigen.h:70
bool factorize()
Factorizes A_ with the selected linear solver. Returns false if it failed or A_ is rank deficient.
Definition: solver_eigen.cpp:523
double final_cost_
Cost after the solve.
Definition: solver_eigen.h:105
unsigned int n_iter_acc_
Accumulated iterations of all solves.
Definition: solver_eigen.h:123
bool analysis_dirty_
The structure changed: symbolic analysis of the factorization needed.
Definition: solver_eigen.h:85
Eigen::SparseMatrix< double > R_
(sorted) R factor of the QR, used for covariances
Definition: solver_eigen.h:90
int numFactorsDerived() const override
Returns the number of factors in the derived solver.
Definition: solver_eigen.cpp:1040
bool structure_dirty_
The structure changed: reindexing needed.
Definition: solver_eigen.h:74
void removeStateBlockDerived(const StateBlockPtr &state_ptr) override
Removes a state block from the derived solver.
Definition: solver_eigen.cpp:976
~SolverEigen() override
Definition: solver_eigen.cpp:146
unsigned int n_interrupted_
Solves terminated by interruption.
Definition: solver_eigen.h:126
Solver manager for WOLF.
Definition: solver_manager.h:84
CovarianceBlocksToBeComputed
Enumeration of covariance blocks to be computed.
Definition: solver_manager.h:89
ReportVerbosity
Enumeration for the verbosity of the solver report.
Definition: solver_manager.h:102
Definition: capture_base.h:23
WOLF_PTR_TYPEDEFS(CaptureLandmarksExternal)
Definition: solver_eigen.cpp:60